package com.tianma.upload.uploadjartest.Test;

import java.lang.reflect.Constructor;

/**
 * @author lgc
 * @createDate 2020/8/5 - 11:18
 */
// enum 本身就是一个class类
public enum EnumSingle {
    INSTANCE("枚举类型",1);
    private Integer index;
    private String message;


    EnumSingle(String message,int index){
        this.message = message;
        this.index =index;
    }
    public static EnumSingle getInstance(){
        return INSTANCE;
    }
    public static void main(String[] args) throws Exception {
        EnumSingle instance = EnumSingle.INSTANCE;
        EnumSingle instances = EnumSingle.getInstance();
        System.out.println("instances = " + instances.index);
        System.out.println("instance = " + instance.message);
        //被idea反编译欺骗 没有无参构造器
      /*  Constructor<EnumSingle> constructor = EnumSingle.class.getDeclaredConstructor(null);
        EnumSingle enumSingle = constructor.newInstance();
        System.out.println("enumSingle = " + enumSingle);*/

        //通过反编译jad工具 反编译发现有EnumSingle(String s, int i)
        /*Constructor<EnumSingle> constructor1 = EnumSingle.class.getDeclaredConstructor(String.class, int.class);
        EnumSingle enumSingle1 = constructor1.newInstance();*/


    }
}
